/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CabecalhoPanel.java
 *
 * Created on 20/10/2011, 23:07:28
 */
package br.com.seguradora.view.panel;

/**
 *
 * @author Diego
 */
public class CabecalhoPanel extends javax.swing.JPanel {

    public CabecalhoPanel() {
        initComponents();
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        codigoLabel = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        bloqueadoCombo = new javax.swing.JComboBox();

        jLabel1.setText("Código:");

        codigoLabel.setText("0");

        jLabel3.setText("Bloqueado:");

        bloqueadoCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Não", "Sim" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(41, 41, 41)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(codigoLabel)
                    .addComponent(bloqueadoCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(177, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(codigoLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(bloqueadoCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox bloqueadoCombo;
    private javax.swing.JLabel codigoLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    // End of variables declaration//GEN-END:variables

    public void setCodigo(long codigo) {
        codigoLabel.setText(String.valueOf(codigo));
    }

    public void setBloqueado(boolean bloqueado) {
        if (bloqueado == true) {
            bloqueadoCombo.setSelectedIndex(1);
        } else {
            bloqueadoCombo.setSelectedIndex(0);
        }
    }

    public long getCodigo() {
        return Long.parseLong(codigoLabel.getText());
    }

    public boolean isBloqueado() {
        return bloqueadoCombo.getSelectedIndex() == 0 ? false : true;
    }

    public void isEnabledComponentBloqueado(boolean isEnabled) {
        bloqueadoCombo.setEnabled(isEnabled);
    }
}
